<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <% String path = request.getContextPath();%>
    	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    	
    	<title>处理举报 </title>
<jsp:include page="/web/manager/inc/header.jsp"></jsp:include>
		<div class="row page-titles mx-0">
                        <div class="col-sm-6 p-md-0">
                            <div class="welcome-text">
                                <h4 class="text-primary">处理举报</h4>
                            </div>
                        </div>
         </div>
         <div class="row">
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-body"  id="body">
                                <div >
                                    <button id="spack" class="btn btn-warning  float-first" data-id="${requestScope.userinfoId}">禁言 </button> 
                                     <button id="black" class="btn btn-danger " data-id="${requestScope.userinfoId}" >拉黑 </button>
                                     <button id="ignore"  class="btn btn-primary " data-id="${requestScope.userinfoId}">忽略 </button>
                                     <button id="delete"  class="btn btn-success float-first" data-id="${requestScope.userinfoId}">删除评论 </button>
                                     <c:forEach items="${requestScope.countComment }" var="count">
                                     	<input  type="checkbox" name="test" value="${count }"/>${count }
                                     </c:forEach>
							   </div>
                                 </div>   
                                    <div class="table-responsive" >
                                    <h3>被举报人：${requestScope.username}</h3>
                                    
                                        <table id="example3" class="display nowrap">
                                            <thead>
                                                <tr>
                                                    <th>评论Id</th>
                                                    <th>举报时间</th>
                                                    <th>举报内容</th>
                                                    <th>举报原因</th>
                                                    <th>举报人</th>
                                                    
                                                </tr>
                                            </thead>
                                            <tbody id="reportList">
                                            	<c:forEach items="${reports }" var="report">
                                                <tr>
                                                	<td>${report.commentId }</td>
                                                	<td>${report.reportTime } </td>
                                                	<td> ${report.comment }</td>
                                                	<td> ${report.reportReason }</td>
                                                	<td> ${report.reportMan }</td>
                                                </tr>
                                                </c:forEach>
                                            </tbody>
                                        </table>
                                    </div>
                                   
                                </div>
                            </div>
                        </div>
                </div>
  <jsp:include page="/web/manager/inc/footer.jsp"></jsp:include>
  <script>
  $(function(){
		$("#example3_paginate").remove();
		$("#example3_info").remove();
	})
  var path = "${pageContext.request.contextPath}";
  //点击忽略按钮，退回到上一次举报列表，同时将这个人1.举报次数清零  2.查看 ischeck=1 执行ajax
  $(function(){
	  $("#ignore").on("click",function(){
		  var userinfoId = $(this).data("id");
		 // console.log(userinfoId);
		  $.post(path+"/ManagerController?action=ignore&id="+userinfoId,function(){
			  window.location.href="http://localhost:8080/spacesys/web/manager/handling-reports.jsp"
		  })
	  })
	  $("#black").on("click",function(){
		  var userinfoId = $(this).data("id");
		  $.post(path+"/ManagerController?action=black&id="+userinfoId,function(){
			  window.location.href="http://localhost:8080/spacesys/web/manager/handling-reports.jsp"
		  })
	  })
	 $("#spack").on("click",function(){
		  var time = prompt("请输入禁言天数：","3");
		  if (time == null || time == "") {
			    return false;
			  } 
		  else {
				  var userinfoId = $(this).data("id");
				  $.post(path+"/ManagerController?action=spack&id="+userinfoId+"&time="+time,function(){
					  window.location.href="http://localhost:8080/spacesys/web/manager/handling-reports.jsp"
				  })
				  
			 }
	    })
	   $("#delete").on("click",function(){
		  var userinfoId = $(this).data("id");
		  var obj = document.getElementsByName('test');
		  var s = '';
		  for (var i = 0; i < obj.length; i++) {
		  if (obj[i].checked)
		  	{ s += obj[i].value + ','}
		  }
		  
		  $.post(path+"/ManagerController?action=deleteComment&id="+userinfoId+"&commentId="+s,function(){
			  window.location.href="http://localhost:8080/spacesys/web/manager/handling-reports.jsp"
		  }) 
	  })
	   
 	 })
  
  
  </script>
